package com.kmxd.ams.core.common.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

/**
 * 实体类型
 *
 * @author nickbi
 */
@Getter
@AllArgsConstructor
public enum PhysicalCategoryEnum {

  /** 纸质 */
  PAPER("1", "纸质"),
  PHOTO("2", "照片"),
  VIDEO_TAPE("3", "录像带"),
  AUDIO_TAPE("4", "录音带"),
  MOVIE("5", "影片"),
  MICRO_FILM("6", "微缩胶片"),
  PHYSICAL("7", "实物"),
  ;

  private String code;
  private String desc;

  public static PhysicalCategoryEnum convert(String type) {
    return Arrays.stream(values()).filter(x -> x.code.equals(type)).findAny().orElse(null);
  }

  @JsonCreator
  public static PhysicalCategoryEnum getValue(String type) {
    return Arrays.stream(values()).filter(x -> Objects.equals(x.code, type)).findAny().orElse(null);
  }
}
